var PeeriusCallbacks = {

    smartRecs: function (jsonData) {

        if (console != null) {
            console.log("PeeriusCallbacks.smartRecs(jsonData)");
            console.log(jsonData);
        }

        if (typeof(renderPeeriusUserPrefences) == "function")renderPeeriusUserPrefences(this.getRecsByPosition(jsonData, "homerecent"));
        if (typeof(renderPopularByCategory) == "function")renderPopularByCategory(this.getRecsByPosition(jsonData, "homepopular"));
        if (typeof(renderUserPersonalized) == "function") renderUserPersonalized(this.getRecsByPosition(jsonData, "productalt"));
        if (typeof(renderZeroSearch) == "function") renderZeroSearch(this.getRecsByPosition(jsonData, "searchjson"));
        if (typeof(renderCheckoutOverview) == "function") renderCheckoutOverview(this.getRecsByPosition(jsonData, "basketjson"));
        if (typeof(renderPage404) == "function") renderPage404(this.getRecsByPosition(jsonData, "page404"));
    },

    getRecsByPosition: function (jsonArray, positionName) {
        for (var i = 0; i < jsonArray.length; i++) {
            if (jsonArray[i].position == positionName) {
                return jsonArray[i].recs.map(function (element) {
                    return element.refCode + "_" + element.id;
                }).join(",");
            }
        }
    },

    info: function (jsonData) {
        if (console != null) {
            console.log("Peerius A/B Testing Info");
            console.log(jsonData);
        }
    }
};